/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rw.magallanes.utilities;

import java.text.DecimalFormat;
import java.text.ParseException;

/**
 *
 * @author Gonzalez
 */
public class DoubleFormat {

    public static String format(int decimals, double value) {
        DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance();
        df.setMaximumFractionDigits(decimals);
        return df.format(value);
    }

    public static double parse(int decimals, String strValue) throws ParseException {
        DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance();
        df.setMaximumFractionDigits(decimals);
        return df.parse(strValue).doubleValue();
    }
}
